home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / include / voronoi.h < prev   
C/C++ Source or Header  |  1994-08-01  |  3KB  |  139 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #define MAXSITES 4096
  18.  
  19. /* GL DRAWING STUFF */
  20.  
  21. /* vertex: x, y */
  22. struct vertstruct {
  23.     float x, y;
  24.     int vpid;
  25.     };
  26.  
  27. /* vertex id w/neighbors */
  28. struct nvertstruct {
  29.     int nbr1, nbr2, onhull;
  30.     int vpid;
  31.     };
  32.  
  33. /* vertex: x, y, theta */
  34. struct vertthetastruct {
  35.     float x, y, theta;
  36.     int e1, e2;
  37.     };
  38.  
  39. /* edge: CLIPPED to reasonable bounds */
  40. struct edgestruct {
  41.     float x1, y1, x2, y2;
  42.     int nbr1, nbr2;
  43.     float xm, ym;        /* halfway between inducing voronoi sites */
  44.     };
  45.  
  46. typedef struct vertstruct VERT;
  47. typedef struct nvertstruct NVERT;
  48. typedef struct vertthetastruct VERTTHETA;
  49. typedef struct edgestruct EDGE;
  50.  
  51. /* triangle: holds POINTERS to three verts */
  52. struct tristruct {
  53.     VERT *v1, *v2, *v3;
  54.     };
  55.  
  56. struct circstruct {
  57.     float cx, cy, r;
  58.     int nbr1, nbr2, nbr3;
  59.     };
  60.  
  61. typedef struct tristruct TRI;
  62. typedef struct circstruct CIRC;
  63.  
  64. #define MAXVERTS (3 * MAXSITES)
  65. #define MAXEDGES (2 * MAXSITES)
  66. #define MAXTRIS  (MAXEDGES)
  67.  
  68. extern VERT GLsites[MAXVERTS];
  69. extern VERT verts[MAXVERTS];
  70. extern EDGE vedges[MAXEDGES];
  71. extern NVERT chverts[MAXVERTS];
  72. extern TRI  tris[MAXTRIS];
  73. extern CIRC circles[MAXTRIS];
  74.  
  75. /* load_vsites(): 
  76.     accept the n voronoi sites (x_n, y_n)
  77.     calculate and store the voronoi diagram over the n sites,
  78.     clipping all infinite edges to bbox: [xmin, ymin, xmax, ymax].
  79.     
  80.     note: if (xmin,ymin,xmax,ymax are all == 0.0), OR
  81.     if these do not enclose the data, a bounding box
  82.      will be computed over the input.
  83.  
  84.     returns:
  85.     -1 if error
  86.      0 otherwise
  87. */
  88. int
  89. load_vsites (
  90.     int n,
  91.     float usites[][2],    /* sites in x,y order */
  92.     float uxmin, float uymin, float uxmax, float uymax);
  93.  
  94. /*
  95.     find_vregion(sid, plen, pverts)
  96.     given a site id 'sid' from 0..nsites-1 inclusive, 
  97.     returns the voronoi polygon associated with that site
  98.     in the array 'pverts', and its length on call stack.
  99.  
  100.     the vertices are returned in counterclockwise order.
  101.  
  102.     returns:
  103.     -1 if error condition
  104.     plen > 2 [i.e., the # of verts in the voronoi polygon] otherwise
  105. */
  106. int
  107. find_vregion (
  108.     int vsid,
  109.     float pverts[][2]);
  110.  
  111. /*
  112.     int
  113.     find_dtriangles (**dtris)
  114.  
  115.     returns:
  116.     -1 if error condition, *dtris == NULL
  117.     o/wise, # of delaunay triangles, *dtris == array of TRIS (see voronoi.h)
  118. */
  119. int
  120. find_dtriangles (
  121.     TRI **dtris);
  122.  
  123. /*
  124.     int
  125.     find_convexhull (**chverts)
  126.  
  127.     returns:
  128.     if error condition
  129.          *chverts == NULL
  130.         returns -1 
  131.     o/wise, 
  132.         *chverts == array of named VERTs (see voronoi.h), in order around convex hull
  133.         *chvert[k].vpid == index of point in point set given to load_vertices()
  134.         returns # of convex hull vertices
  135. */
  136. int
  137. find_convexhull(
  138.     NVERT **chvertices);
  139.